package net.net23.sysdent;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;

public class WindowUtility {

	public static void center(Component component, int width, int height) {
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		int w = (int) ((d.getWidth() - width) / 2);
		int h = (int) ((d.getHeight() - height) / 2);
		component.setBounds(w, h, width, height);
	}

	public static void centerRelative(Component parent, Component component,
			int width, int height) {
		Dimension d = parent.getSize();
		int w = (int) ((d.getWidth() - width) / 2);
		int h = (int) ((d.getHeight() - height) / 2);
		component.setBounds(w, h, width, height);
	}
}
